home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!marnold
- From: marnold@netcom.com (Matt Arnold)
- Subject: Re: Is there a standard for * and & placement style?
- Message-ID: <marnoldDn27q9.Is0@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <3128BD31.4AF8@wildfire.com>
- Date: Tue, 20 Feb 1996 05:39:45 GMT
- Sender: marnold@netcom12.netcom.com
-
- Stonewall Ballard <stoney@wildfire.com> writes:
-
- >I'm trying to find out whether there is a "standard" for the
- >placement of * and &. A survey of C++ texts shows that most use
-
- >Form 1
- > int& foo;
- > int* foo;
-
- >while some use
-
- >Form 2
- > int& foo;
- > int *foo;
-
- >and nobody uses (although I've seen this a lot in code)
-
- >Form 3
- > int &foo;
- > int *foo;
-
- I can't stand this form!
-
- >The ARM and the latest C++ working paper both use form 1. The
- >most well-known user of form 2 is Scott Meyers in his Effective
- >C++ books. People I work with use form 3.
-
- >Imagine that you were given a class framework to use and extend.
- >Would you expect that the placement of & and * follow one of the
- >above schemes? Do you perceive that there is a standard for the
- >placement of * and &? If so, what is it?
-
- There is probably no standard, just religiously held opinions.
-
- >Please reply by email to stoney@wildfire.com
-
- My personal preference is Form 1, and I have a logical reason: It
- seems to me that that "pointer-ness" (*) or "reference-ness" (&) is
- certinaly part of the variable *type*, not part of the variable. It
- therefore seems logical to associate * or & with type identifier
- rather than the variable name. For me, this creates a distinct
- visual separation between types and variables.
-
-
- You forgot Form 4
-
- int & foo;
- int * foo;
-
- ;-)
-
- Regards,
- -------------------------------------------------------------------------
- Matt Arnold | | ||| | |||| | | | || ||
- marnold@netcom.com | | ||| | |||| | | | || ||
- Boston, MA | 0 | ||| | |||| | | | || ||
- 617.389.7384 (h) 617.576.2760 (w) | | ||| | |||| | | | || ||
- C++, MIDI, Win32/95 developer | | ||| 4 3 1 0 8 3 || ||
- -------------------------------------------------------------------------
-